<template>
  <div id="app">
    <router-view />
    <account :isPage="false"/>
  </div>
</template>

<script>
import account from '@/components/account'
import { mapGetters } from 'vuex'
export default {
  name: 'App',
  components: {
    account
  },
  computed: {
    ...mapGetters(['appInfo'])
  },
  created () {
    if (window.frames.length === parent.frames.length) {
      this.$xzReg('inform_login', () => {
        const token = this.$store.state.user.token
        this.$store.dispatch('user/getToken').then(res => {
          this.$store.dispatch('user/getUserInfo').then(() => {
            this.$xzReportInfo(2734, {
              scene: 210,
              param1: this.$store.getters.userInfo.is_member ? 1 : 0
            })
            this.$store.commit('user/SET_HASLOGIN', true)
          })
          if (process.env.VUE_APP_NAME === 'i18n') {
            this.$store.dispatch('user/setACDialogType', '')
            this.$router.push('/usercenter')
          }
        }).catch(e => {
          token && this.$store.dispatch('user/resetUserInfo', false)
        })
      })
    }
    this.$xzReg('inform_language', (r) => {
      location.reload()
    })
  },
  mounted () {
    if (process.env.VUE_APP_NAME === 'i18n') {
      this.$xz('xz_page_load_finished', 'XZUserCenter')
    }
  }
}
</script>
